import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UserWithdrawVo, UserWithdrawForm, UserWithdrawQuery } from '@/api/pay/userwithdraw/types';

/**
 * 查询用户提现记录列表
 * @param query
 * @returns {*}
 */

export const listUserWithdraw = (query?: UserWithdrawQuery): AxiosPromise<UserWithdrawVo[]> => {
  return request({
    url: '/lawyer/userWithdraw/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户提现记录详细
 * @param id
 */
export const getUserWithdraw = (id: string | number): AxiosPromise<UserWithdrawVo> => {
  return request({
    url: '/lawyer/userWithdraw/' + id,
    method: 'get'
  });
};

/**
 * 新增用户提现记录
 * @param data
 */
export const addUserWithdraw = (data: UserWithdrawForm) => {
  return request({
    url: '/lawyer/userWithdraw/saveUserWithdraw',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户提现记录
 * @param data
 */
export const updateUserWithdraw = (data: UserWithdrawForm) => {
  return request({
    url: '/lawyer/userWithdraw/updateUserWithdraw',
    method: 'post',
    data: data
  });
};

/**
 * 删除用户提现记录
 * @param id
 */
export const delUserWithdraw = (id: string | number | Array<string | number>) => {
  return request({
    url: '/lawyer/userWithdraw/removeUserWithdraw/' + id,
    method: 'delete'
  });
};

/**
 * 驳回用户提现
 * @param data
 */
export const rejectWithdraw = (data: UserWithdrawForm) => {
  return request({
    url: '/lawyer/userWithdraw/rejectWithdraw',
    method: 'post',
    data: data
  });
};

export const submitWithdraw = (withdrawNumber: string) => {
  const data = {
    withdrawNumber
  };
  return request({
    url: '/lawyer/userWithdraw/submitWithdraw',
    method: 'post',
    data: data
  });
};
